3 Lecture

CS201

Midterm & Final Term Short Notes

First C program

The first C program is often a simple "Hello, World!" program, which is a basic program that outputs the text "Hello, World!" to the console or terminal. This program is used as an introductory example to demonstrate the basic structure of a C p


Important Mcq's
Midterm & Finalterm Prepration
Past papers included

Download PDF
  1. What is the purpose of the "Hello, World!" program? A. To introduce the basics of C programming B. To display "Hello, World!" on the screen C. Both A and B

Answer: C

  1. Which function is used to display text on the screen in a C program? A. print B. println C. printf

Answer: C

  1. What is the syntax for writing a "Hello, World!" program in C? A. print("Hello, World!") B. printf("Hello, World!"); C. println("Hello, World!");

Answer: B

  1. Which keyword is used to indicate the beginning of the main function in a C program? A. function B. main C. start

Answer: B

  1. Which symbol is used to end a statement in a C program? A. ; B. : C. ,

Answer: A

  1. Which header file must be included to use printf() function in a C program? A. <stdio.h> B. <stdlib.h> C. <string.h>

Answer: A

  1. Which type of brackets are used to enclose the main function in a C program? A. () B. {} C. []

Answer: B

  1. Which operator is used to assign a value to a variable in C? A. = B. == C. :

Answer: A

  1. Which data type is used to store whole numbers in C? A. float B. char C. int

Answer: C

  1. What is the output of the "Hello, World!" program? A. Hello, World! B. World, Hello! C. Hello!

Answer: A



Subjective Short Notes
Midterm & Finalterm Prepration
Past papers included

Download PDF
  1. What is the significance of the "Hello, World!" program in C programming? Answer: The "Hello, World!" program is often used as an introduction to the basics of C programming, and it is considered a starting point for beginners to learn about the syntax and structure of a C program.

  2. What is the purpose of including the stdio.h header file in a C program? Answer: The stdio.h header file is necessary for using input/output functions in a C program, such as the printf() function, which is used to display text on the screen.

  3. What is the purpose of the main() function in a C program? Answer: The main() function is the entry point of a C program, and it contains the code that is executed when the program is run.

  4. How is a variable declared in a C program? Answer: A variable is declared by specifying its data type and name, such as int x; for declaring an integer variable named x.

  5. What is the syntax for displaying the value of a variable in a C program? Answer: The printf() function is used to display the value of a variable, and the variable name is enclosed in the % symbol followed by its data type, such as %d for an integer variable.

  6. What is the purpose of the return statement in the main() function? Answer: The return statement is used to indicate the exit status of a program, and it returns a value to the operating system.

  7. What is the purpose of the escape sequence \n in a C program? Answer: The escape sequence \n is used to insert a new line character in a string, which is used for formatting the output in a C program.

  8. What is the purpose of the semicolon (;) in a C program? Answer: The semicolon (;) is used to indicate the end of a statement in a C program.

  9. How is a comment added to a C program? Answer: A comment is added to a C program using the /* */ symbols to enclose the text, or by using // to indicate a single line comment.

  10. What is the purpose of the #include directive in a C program? Answer: The #include directive is used to include header files in a C program, which contain predefined functions and variables used in the program.

The "Hello, World!" program is the simplest program in C programming language. It is typically the first program that beginners learn when starting to learn programming in C. The program is a short and basic one, with the sole purpose of displaying the text "Hello, World!" on the screen. The program consists of a single line of code, which uses the printf() function to output the text "Hello, World!" to the console or terminal. The printf() function is defined in the stdio.h header file, which is included at the beginning of the program. The program starts with the main() function, which is the entry point of the program. It is mandatory for every C program to have a main() function. In the main() function, the printf() function is used to display the "Hello, World!" text on the screen. The printf() function takes the text to be displayed as an argument and uses the format specifier "%s" to indicate that the argument is a string of characters. Once the program is written, it is compiled and executed. Compiling the program means converting the human-readable source code into machine-readable code that can be executed by the computer. Execution of the program involves running the compiled code, which in turn displays the "Hello, World!" text on the screen. The "Hello, World!" program may seem trivial, but it is an important starting point for beginners to learn the basic syntax and structure of a C program. By learning how to write, compile, and execute the "Hello, World!" program, beginners can gain a solid foundation in programming and build on this foundation to learn more complex concepts and programming techniques.